var begin_no = 0;

var page_size = 10;


$(document).ready(function(){
    getMessageList()
});


//获取消息列表
function getMessageList() {
    $.ajax({
        type: "post",
        url: '/mep/getOrderMessages.do',
        dataType: "json",
        data: {
            'begin_no':begin_no,
            'page_size':page_size
        },
        success: function(resp){
            console.log(resp);
            if(resp.result==="success"){
                begin_no = begin_no+page_size;
                showMessageList(resp.list);
            }else{
                console.log("get_order_message_error!");
            }
        }
    });
}

//显示消息列表
function showMessageList(list) {
    if(list.length<page_size){
        $('#more').hide();
    }
    var html = "";
    for(var i =0;i<list.length;i++){
        if(list[i].check_status===1){
            html = html+"<li onclick=\"location.href=ctx+'/mep/toCheckOrder.do?message_id="+list[i].message_id+
                "&order_no="+list[i].order_no+"'\">";
        }else{
            html = html+"<li class=\"unread\" onclick=\"location.href=ctx+'/mep/toCheckOrder.do?message_id="+list[i].message_id+
                "&order_no="+list[i].order_no+"'\">";
        }
        html = html + "<h1>订单消息提示<span>"+list[i].create_time+"</span></h1>" +
            "<p>"+list[i].message_content+"</p>" +
            "</li>"
    }
    $('#order_list').append(html);
}